package com.buwei.container;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.handler.annotation.Payload;

import com.buwei.infrastructure.annotation.EventHandler;
import com.buwei.module.log.domain.event.UserOperatedEvent;
import com.buwei.module.one.domain.event.EmployeeCreatedEvent;
import com.buwei.module.one.domain.event.EmployeeTransferredEvent;


@EnableBinding(Sink.class)
class AppEventHandler{
	
	private static Logger logger = LoggerFactory.getLogger(AppEventHandler.class);

    /**
     * 
     * @Description : 发现用接口Event来接收事件会反序列化异常，用具体的事件类来接收则正常
     * ---------------------------------
     * @Author : Bu Wei
     * @Date : Created at 2018年4月27日 下午9:29:34
     */
//	@EventHandler(eventType = EmployeeCreatedEvent.EVENT_TYPE)
	@EventHandler(EmployeeCreatedEvent.EVENT_TYPE)
    public void handleEmployeeCreatedEvent(@Payload EmployeeCreatedEvent event) {
    	logger.info("Received EmployeeCreatedEvent: " + event);
     }
 
//	@EventHandler(eventType = EmployeeCreatedEvent.EVENT_TYPE)
	@EventHandler(EmployeeTransferredEvent.EVENT_TYPE)
    public void handleEmployeeTransferredEvent(@Payload EmployeeTransferredEvent event) {
    	logger.info("Received EmployeeTransferredEvent: " + event);
     }
	
	@EventHandler(UserOperatedEvent.EVENT_TYPE)
    public void handleUserOperatedEvent(@Payload UserOperatedEvent event) {
    	logger.info("Received UserOperatedEvent: " + event);
     }
	
}
